import {
    API_SITE_CHECK_COLLECT,
    API_SITE_COLLECT,
    API_SITE_COUNT,
    API_SITE_LIST,
    API_SITE_PUSH,
    API_SITE_RANDOM,
    API_SITE_UN_COLLECT
} from "@/constant/api";
import {Page} from "@/entity/page";
import {Site} from "@/entity/site";

export default new class captcha {
    /**
     * 获取站点信息列表
     */
    getList = (page?: Page, site?: Site) => {
        return useUtils().HttpUtils.post(API_SITE_LIST, {
            ...site,
            ...page,
        });
    }

    /**
     * 获取随机站点信息
     */
    getRandom = (limit: number, classifyId?: string) => {
        return useUtils().HttpUtils.get(API_SITE_RANDOM + '/' + limit, {classifyId});
    }

    /**
     * 获取站点信息
     */
    get = (id: string) => {
        return useUtils().HttpUtils.get(API_SITE_LIST + '/' + id);
    }

    /**
     * 收藏站点
     */
    collect = (id: string) => {
        return useUtils().HttpUtils.get(API_SITE_COLLECT + '/' + id);
    }

    /**
     * 取消收藏站点
     */
    unCollect = (id: string) => {
        return useUtils().HttpUtils.get(API_SITE_UN_COLLECT + '/' + id);
    }

    /**
     * 检查是否收藏站点
     */
    checkCollect = (id: string) => {
        return useUtils().HttpUtils.get(API_SITE_CHECK_COLLECT + '/' + id);
    }

    /**
     * 用户提交站点
     */
    push = (site: Site) => {
        return useUtils().HttpUtils.post(API_SITE_PUSH, {...site});
    }

    /**
     * 查询站点数量
     */
    getCount = () => {
        return useUtils().HttpUtils.get(API_SITE_COUNT);
    }
};